package com.ruoyi.common.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "oss")
public class OssConfig {

    /**
     * OSS 对外服务的访问域名
     */
    private static String endpoint;

    /**
     * OSS 存储空间访问密钥
     * 用于标识用户
     */
    private static String accessKeyId;


    /**
     * OSS 存储空间访问密钥
     * 用户用于加密签名字符串
     */
    private static String keySecret;

    /**
     * OSS 存储空间名称
     */
    private static String bucketName;


    public static String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        OssConfig.endpoint = endpoint;
    }

    public static String getAccessKeyId() {
        return accessKeyId;
    }

    public void setAccessKeyId(String accessKeyId) {
        OssConfig.accessKeyId = accessKeyId;
    }

    public static String getKeySecret() {
        return keySecret;
    }

    public void setKeySecret(String keySecret) {
        OssConfig.keySecret = keySecret;
    }

    public static String getBucketName() {
        return bucketName;
    }

    public void setBucketName(String bucketName) {
        OssConfig.bucketName = bucketName;
    }

    @Bean
    public OSS getOssClient()
    {
        return new OSSClientBuilder().build(endpoint, accessKeyId,keySecret);

    }
}
